package oj;

import java.util.Scanner;
import java.util.Stack;

public class Day41S {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
            int n=Integer.parseInt(sc.nextLine());
            String[] s=sc.nextLine().split(" ");
            Stack<String> stack=new Stack<>();
            int sum=0;
            for(int i=0;i<n;i++){
                if(!s[i].equals("+") && !s[i].equals("-")  && !s[i].equals("*") && !s[i].equals("/")){
                    stack.push(s[i]);
                }else{
                    int a=Integer.parseInt(stack.pop());
                    int b=Integer.parseInt(stack.pop());
                    if(s[i].equals("+")){
                        sum=a+b;
                    }else if(s[i].equals("-")){
                        sum=a-b;
                    }else if(s[i].equals("*")){
                        sum=a*b;
                    }else if(s[i].equals("/")){
                        sum=a/b;
                    }
                    stack.push(String.valueOf(sum));
                }
            }
            System.out.println(stack.pop());
        }
    }
}
